package Sort;

import java.util.Arrays;

public class BubbleSort {
    public static void main(String[] args) {
        int[] arr = new int[]{1,3,5,2,4,6,0};
        bubbleSort(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void bubbleSort(int[] arr){
        for(int i = 0;i<arr.length;i++){
            int flag = 0;
            for (int j = 0;j<arr.length-i-1;j++){
                if(arr[j] >=arr[j+1]){
                    flag = 1;
                    int temp = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = temp;
                }
            }
            if(flag == 0){
                break;
            }
        }
    }
}
